/*     */ package com.zimbra.cs.service.admin;
/*     */ 
/*     */ import com.zimbra.common.account.Key.AccountBy;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.soap.Element;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.account.Account;
/*     */ import com.zimbra.cs.account.AccountServiceException;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*     */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*     */ import com.zimbra.soap.JaxbUtil;
/*     */ import com.zimbra.soap.ZimbraSoapContext;
/*     */ import com.zimbra.soap.admin.message.RemoveAccountAliasRequest;
/*     */ import com.zimbra.soap.admin.message.RemoveAccountAliasResponse;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class RemoveAccountAlias
/*     */   extends AdminDocumentHandler
/*     */ {
/*  46 */   private static final String[] TARGET_ACCOUNT_PATH = { "id" };
/*     */   
/*  48 */   protected String[] getProxiedAccountPath() { return TARGET_ACCOUNT_PATH; }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean domainAuthSufficient(Map context)
/*     */   {
/*  55 */     return true;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean defendsAgainstDelegateAdminAccountHarvesting()
/*     */   {
/*  63 */     return true;
/*     */   }
/*     */   
/*     */   public Element handle(Element request, Map<String, Object> context)
/*     */     throws ServiceException
/*     */   {
/*  69 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*  70 */     Provisioning prov = Provisioning.getInstance();
/*     */     
/*  72 */     RemoveAccountAliasRequest req = (RemoveAccountAliasRequest)JaxbUtil.elementToJaxb(request);
/*  73 */     String id = req.getId();
/*  74 */     String alias = req.getAlias();
/*     */     
/*  76 */     Account account = null;
/*  77 */     if (id != null) {
/*  78 */       account = prov.get(Key.AccountBy.id, id, zsc.getAuthToken());
/*     */     }
/*     */     try
/*     */     {
/*  82 */       defendAgainstAccountOrCalendarResourceHarvesting(account, Key.AccountBy.id, id, zsc, Rights.Admin.R_removeAccountAlias, Rights.Admin.R_removeCalendarResourceAlias);
/*     */     }
/*     */     catch (AccountServiceException ase) {}
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*  90 */     String acctName = "";
/*  91 */     if (account != null) {
/*  92 */       acctName = account.getName();
/*     */     }
/*     */     
/*     */ 
/*  96 */     checkDomainRightByEmail(zsc, alias, Rights.Admin.R_deleteAlias);
/*     */     
/*     */ 
/*  99 */     prov.removeAlias(account, alias);
/*     */     
/* 101 */     ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "RemoveAccountAlias", "name", acctName, "alias", alias }));
/*     */     
/*     */ 
/* 104 */     return zsc.jaxbToElement(new RemoveAccountAliasResponse());
/*     */   }
/*     */   
/*     */ 
/*     */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*     */   {
/* 110 */     relatedRights.add(Rights.Admin.R_removeAccountAlias);
/* 111 */     relatedRights.add(Rights.Admin.R_removeCalendarResourceAlias);
/* 112 */     relatedRights.add(Rights.Admin.R_deleteAlias);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/RemoveAccountAlias.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */